package com.jspxcms.core.repository;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;

import com.jspxcms.core.domain.UserDetail;

public interface UserDetailDao extends Repository<UserDetail, Integer> {
	public UserDetail findOne(Integer id);

	public UserDetail save(UserDetail bean);

	public void delete(UserDetail bean);

    @Modifying
    @Query("update UserDetail a set a.score = a.score + ?2, a.scoreFavorite = a.scoreFavorite + ?2 where a.user.id = ?1")
    public int updateScoreFavorite(Integer userId, Integer score);

    @Modifying
    @Query("update UserDetail a set a.score = a.score + ?2, a.scoreStudy = a.scoreStudy + ?2 where a.user.id = ?1")
    public int updateScoreStudy(Integer userId, Integer score);

    @Modifying
    @Query("update UserDetail a set a.score = a.score + ?2 where a.user.id = ?1")
    public int updateScore(Integer id, Integer score);

    @Modifying
    @Query("update UserDetail a set a.hospital = ?2 where a.user.id = ?1")
    public void updateHospital(Integer userId, String hospital);


    // --------------------

}
